package org.example.project.search.ui

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

/**
 * 热搜榜卡片
 */
@Composable
fun HotSearchList(title: String, list: List<Pair<String, String>>, modifier: Modifier = Modifier) {
    Column(
        modifier.fillMaxWidth()
            .padding(top = 8.dp)
            .background(
                color = Color.White, shape = RoundedCornerShape(16.dp)
            ) // 设置背景色和圆角形状
            .padding(start = 12.dp, top = 8.dp, end = 12.dp, bottom = 12.dp),
    ) {
        Row(Modifier.padding(bottom = 12.dp)) {
            Text(title, fontSize = 15.sp, fontWeight = FontWeight.W500)
            Spacer(Modifier.weight(1f))
            Img(12.dp)
            Spacer(Modifier.width(5.dp))
        }
        list.forEachIndexed { index, item ->
            Row(
                modifier = Modifier.fillMaxWidth(),
                verticalAlignment = Alignment.CenterVertically
            ) {
                Text(
                    (index + 1).toString(),
                    modifier = Modifier.padding(start = 10.dp, end = 10.dp).width(18.dp)
                )
                Text(
                    item.first,
                    fontSize = 12.sp,
                    modifier = Modifier.fillMaxWidth(0.7f)
                )
                Spacer(Modifier.weight(1f))
                Text(
                    item.second,
                    fontSize = 11.sp,
                    color = Color(0xaa000000)
                )
            }
            if (index != list.size - 1) {
                Divider(
                    modifier = Modifier.padding(top = 8.dp, bottom = 8.dp),
                    thickness = 0.5.dp
                )
            }
        }
    }
}